package com.asf.sofom.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.asf.sofom.domain.OEcivil;

@Repository(value="ecivilDao")
public class JPAEcivil implements EcivilDao{

	private EntityManager em = null;
	
	@PersistenceContext
	public void setEntityManager(EntityManager em){
		this.em = em;
	}
	
	@Transactional(readOnly = true)
	@SuppressWarnings("unchecked")
	public List<OEcivil> getEcivil() {
		TypedQuery<OEcivil> tq = (TypedQuery<OEcivil>) em.createNativeQuery("Select * from personas_ecivil", OEcivil.class);
		List<OEcivil> lc = tq.getResultList();
		return lc;
	}

	@Transactional(readOnly = false)
	public void setEcivil(OEcivil ecivil) {
		em.merge(ecivil);
		
	}

}
